/*
 * LogManager.cpp
 *
 *  Created on: Oct 1, 2010
 *      Author: gabriel
 */

#include "LogManager.h"

namespace Utility
{
	LogManager::LogManager( std::string name , std::string format ) : logname( name ), dateformat( format )	{}

	LogManager::~LogManager()	{}

	bool LogManager::saveLog ( std::string msg )
	{
		try
		{
			std::ofstream LogFile ( logname.c_str() , std::ios::app );
			LogFile << LogManager::getInt().c_str() << "]> " << msg.c_str() << std::endl;
			LogFile.close();
		}
		catch ( std::exception e )
		{
			return false;
		}

		return true;
	}

	std::string LogManager::getInt ()
	{
		using namespace boost::posix_time;

		ptime now = microsec_clock::local_time();

		return to_iso_extended_string( now );
	}

	bool LogManager::setName ( std::string name )
	{
		logname = name;
		return true;
	}

	bool LogManager::setFormat ( std::string format )
	{
		dateformat = format;
		return true;
	}
}
